package com.example.module_web.base;

import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

/**
 * Created by Administrator on 2017/11/3.
 */

public abstract class BaseFragment<B extends ViewDataBinding> extends Fragment {
    private B binding;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding= DataBindingUtil.inflate(inflater,setLayoutId(),container,false);
        init(binding);
        return binding.getRoot();
    }
    public abstract int setLayoutId();
    public abstract void init(B binding);
    public void toast(Object s){
        if (getContext()==null)
            return;
        Toast.makeText(getContext(), String.valueOf(s), Toast.LENGTH_SHORT).show();
    }
}
